<!--工作经历表单-->
<template>
  <div class="form">
    <yd-cell-group>
      <yd-cell-item>
        <span slot="left" class="label required">入校日期</span>
        <xf-date-picker
          :valid="[{required: true, msg: '请选择入校日期'}]"
          v-model="form.aae030"
          ref="aae030"
          placeholder="请选择入校日期"
          :endDate="new Date()"
          slot="right"></xf-date-picker>
      </yd-cell-item>
      <yd-cell-item>
        <span slot="left" class="label required">离校日期</span>
        <xf-date-picker
          :valid="[{required: true, msg: '请选择离校日期'}]"
          v-model="form.aac046"
          ref="aac046"
          placeholder="请选择离校日期"
          slot="right"></xf-date-picker>
      </yd-cell-item>
      <yd-cell-item>
        <span slot="left" class="label required">所在学校</span>
        <xf-input
          slot="right"
          :valid="[{required: true, msg: '请输入所在学校'}]"
          v-model="form.aac045"
          ref="aac045"
          placeholder="请输入所在学校"></xf-input>
      </yd-cell-item>
      <yd-cell-item>
        <span slot="left" class="label required">所学专业</span>
        <xf-picker
          v-model="form.acc01g"
          ref="acc01g"
          :valid="[{required: true, msg: '请选择所学专业'}]"
          placeholder="请选择所学专业"
          :list="profession"
          search
          slot="right"></xf-picker>
      </yd-cell-item>
      <yd-cell-item>
        <span slot="left" class="label required">所获学位</span>
        <xf-picker
          v-model="form.aac037"
          ref="aac037"
          :valid="[{required: true, msg: '请选择所获学位'}]"
          placeholder="请选择所获学位"
          :list="degree"
          search
          slot="right"></xf-picker>
      </yd-cell-item>
      <yd-cell-item>
        <span slot="left" class="label required">所获学历</span>
        <xf-picker
          v-model="form.atc011"
          ref="atc011"
          :valid="[{required: true, msg: '请选择所获学历'}]"
          placeholder="请选择所获学历"
          :list="edu"
          slot="right"></xf-picker>
      </yd-cell-item>
      <!--<yd-cell-item>
        <span slot="left" class="label required">教育类别</span>
        <xf-picker
          v-model="form.aac0d3"
          ref="aac0d3"
          :valid="[{required: true, msg: '请选择教育类别'}]"
          placeholder="请选择教育类别"
          :list="eduType"
          slot="right"></xf-picker>
      </yd-cell-item>
      <yd-cell-item>
        <span slot="left" class="label required">学习形式</span>
        <xf-picker
          v-model="form.aac0d8"
          ref="aac0d8"
          :valid="[{required: true, msg: '请选择学习形式'}]"
          placeholder="请选择学习形式"
          :list="learn"
          slot="right"></xf-picker>
      </yd-cell-item>-->
    </yd-cell-group>
    <div class="right-bottom">
      <mt-button type="default" size="small" @click="cancel">取消</mt-button>
      <mt-button type="primary" size="small" @click="onSubmit">保存</mt-button>
    </div>
  </div>
</template>
<script>
  import XfDatePicker from '../../../components/xf-date-picker/xf-date-picker.vue'
  import XfInput from '../../../components/xf-input/xf-input.vue'
  import XfPicker from '../../../components/xf-picker/xf-picker.vue'
  import {dics, getDics} from '../../../common/js/dictionaries'
  import {validate, echo} from '../../../common/js/util'

  export default {
    components: {
      XfPicker,
      XfInput,
      XfDatePicker},
    name: 'form-edu',
    props: {
      detail: {type: null, default: () => { return {} }}
    },
    computed: {},
    data() {
      return {
        form: {
          personId: '',
          aac0d0: '',
          aae030: '', // 开始时间
          aac046: '', // 结束时间
          aac045: '', // 毕业学校
          acc01g: '', // 专业
          aac037: '', // 学位
          atc011: '', // 学历
          aac0d3: '', // 教育类别
          aac0d8: '' // 学习形式
        },
        profession: [],
        edu: [],
        degree: [],
        eduType: [],
        learn: []
      }
    },
    methods: {
      cancel() {
        this.$emit('cancel')
      },
      onSubmit() {
        this.form.personId = this.$route.query.id
        validate.call(this, this.form).then(() => {
          this.$post('/admin/person/sapi/personal/records/perEntry/update/education', this.form, loading => {
            this.$message.loading(loading)
          }).then(res => {
            this.$emit('save')
          })
        })
      },
      getDics() {
        getDics(dics.profession, dics.edu, dics.degree, dics.eduType, dics.learn).then(res => {
          this.profession = res[0]
          this.edu = res[1]
          this.degree = res[2]
          this.eduType = res[3]
          this.learn = res[4]
        })
      }
    },
    created() {
      this.getDics()
      echo(this.form, this.detail)
    }
  }
</script>
